.HE "/ /Description of Program Spectral/\*(DA/"
.na
INTRODUCTION
.sp
The purpose of program spectral is to check the quality of
multiplier and modulus of linear congruential random number
generators. One-parameter and two-parameter generators can be handled.
.sp
Program spectral implements Knuth's Algorithm S (The Spectral
Test) [1, pp. 89-113].  The underlying theory is described on
pages 89-98 of [1].  The algorithm implemented is described on
pages 98-105.  The generalization described in exercise 24,
page 113 of [1] has also been implemented.
.sp
Program spectral employs software written by Steve Moshier [2]
to do 100-digit extended precision arithmetic.
.sp
This document describes how to use program spectral.
.sp 2
HOW TO USE PROGRAM SPECTRAL
.sp
Program spectral resides on disk as spectral.exe.  Standard units
are used for input and output:
.sp
.ai
	stderr	- Prompts for inputs and and error messages
	stdin	- Input data
	stdout	- Results
.sp
.fi
Start program spectral by issuing the command
.sp
	spectral
.sp
at the command line.
.sp
My favorite input technique is to prepare an input file with the
required data, one item per line.  Then the redirect the input unit
with:
.sp
	sepctral < [file name]
.sp
If you decide to enter the data directly, you will be prompted for
input data as follows:
.sp
.ai
	How Many Multipliers? [1 or 2]:
	Enter Multiplier:
	Enter Modulus:
	Enter Maximum Dimension:
.sp
.fi
The text shown is produced when you respond '1' to the first prompt.
You must enter either 1 or 2.  If you don't, program spectral issues a
warning message and asks you to reenter the input:
.sp
.ai
	How Many Multipliers? [1 or 2]: 3
	Incorrect Response: 3
	How Many Multipliers? [1 or 2]:
.sp
.fi
.ne 2
The following prompts are produced when you respond '2' to the
first prompt:
.sp
.ai
	How Many Multipliers? [1 or 2]: 2
	Enter First  Multiplier:
	Enter Second Multiplier:
	Enter Modulus:
	Enter Maximum Dimension:
.sp
.fi
For example, to replicate the numbers on line 27, page 102 of [1] your
responses must be:
.sp
.ai
	How Many Multipliers? [1 or 2]: 1
	Enter Multiplier:               314159269
	Enter Modulus:                  2147483647
	Enter Maximum Dimension:        6
.sp
.fi
The only two-parameter generator illustrated in [1] is given on line~28.
Here is what your responses must be:
.sp
.ai
	How Many Multipliers? [1 or 2]: 2
	Enter First  Multiplier:        271828183
	Enter Second Multiplier:        -314159269
	Enter Modulus:                  2147483647
	Enter Maximum Dimension:        6
.sp
.fi
A requirement of the Spectral Test is that the multiplier(s) and the
modulus be relatively prime. When this is not the case, you will be
advised with a printout like the following:
.sp
.ai
	Multiplier and modulus not relatively prime.
	GCD of Multiplier and Modulus =  xxxx
	Error(s) detected in input data
.sp
.fi
The minimum dimension that is tested is 2. If you enter something
less than that your input is silently ignored.
.sp 2
OUTPUT FROM PROGRAM SPECTRAL
.sp
Standard Printouts
.br
------------------
.sp
The first few lines of output echo your inputs. Thereafter,
the results of the Spectral Test are printed - two lines per
dimension requested.  For example, when the test cited above
for line 27 from [1] is run, the following output is produced:
.sp
.ai
                1                    Number of Multipliers
                314159269            Multiplier
                2147483647           Modulus
                6                    Maximum Dimension of Test
2-Dimensional Accuracy =  1432232969  No. Bits:  15.2
2-Dimensional Merit    =  2.10        (Good > 0.1, Great > 1.0)
3-Dimensional Accuracy =  899290      No. Bits:  9.9
3-Dimensional Merit    =  1.66        (Good > 0.1, Great > 1.0)
4-Dimensional Accuracy =  36985       No. Bits:  7.6
4-Dimensional Merit    =  3.14        (Good > 0.1, Great > 1.0)
5-Dimensional Accuracy =  3427        No. Bits:  5.9
5-Dimensional Merit    =  1.69        (Good > 0.1, Great > 1.0)
6-Dimensional Accuracy =  1144        No. Bits:  5.1
6-Dimensional Merit    =  3.60        (Good > 0.1, Great > 1.0)
.sp
.fi
The numbers that you see in this example exactly replicate those
given in [1].  The output you see here has been cropped to fit on
the page.
.sp
Error Printouts
.br
---------------
.sp
As stated previously, you must enter 1 or 2 to the first prompt.
Failure to do so can result is severe mental anguish, to wit:
.sp
.ai
	How Many Multipliers? [1 or 2]: 3 <-- Uncalled for
	Incorrect Response: 3
	How Many Multipliers? [1 or 2]:
.sp
.fi
It is a requirement that the multiplier(s) under test and the
modulus be relatively prime.  When this is not the case, you
are shown the error of your ways as follows:
.sp
.ai
	How Many Multipliers? [1 or 2]: 1
	Enter Multiplier:		314159269
	Enter Modulus:			2147483639
	Multiplier and modulus not relatively prime.
	GCD of Multiplier and Modulus =  17
	Error(s) detected in input data
.sp
.fi
REFERENCES
.sp
1.~Donald E. Knuth, The Art of Computer Programming, Second
Edition, Vol. 2, Seminumerical Algorithms, Addison-Wesley,
Reading, Mass. (1981).
.sp
2.~Steven L. Moshier, Methods and Programs for Mathematical
Functions, Prentice-Hall (1989)
